﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NuiBlue.Bluetooth;
using System.Xml.Linq;

namespace WinFormBrowser
{
    public partial class Form1 : Form
    {
        public delegate void statusDelegate(object sender, string status);

        BluetoothController bc;
        public Form1()
        {
            InitializeComponent();

            bc = new BluetoothController();
            bc.dataDownloaded += new BluetoothController.DataDownloadedHandler(bc_dataDownloaded);
            bc.StatusUpdate += new BluetoothController.StatusEventHandler(bc_StatusUpdate);
        }

        void statusUpdate(object sender, string status)
        {
            lstUpdate.Items.Add(status);
        }

        void bc_dataDownloaded(object sender, BluetoothEventArgs e)
        {
            //throw new NotImplementedException();
        }

        void bc_StatusUpdate(object sender, string status)
        {
            lstUpdate.BeginInvoke(new statusDelegate(statusUpdate), sender, status);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            bc.setAddress(txtAddress.Text);
            bc.setPin(txtPin.Text);

            bc.setMaxFiles(1);
            bc.downloadData(true, BluetoothController.Type.image, null, null);
        }
    }
}
